package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallIssue;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HaogoumallIssueMapper {
    @Delete({
        "delete from haogoumall_issue",
        "where issue_id = #{issueId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer issueId);

    @Insert({
        "insert into haogoumall_issue (issue_id, issue_question, ",
        "issue_answer, issue_add_time, ",
        "issue_update_time, issue_deleted)",
        "values (#{issueId,jdbcType=INTEGER}, #{issueQuestion,jdbcType=VARCHAR}, ",
        "#{issueAnswer,jdbcType=VARCHAR}, #{issueAddTime,jdbcType=TIMESTAMP}, ",
        "#{issueUpdateTime,jdbcType=TIMESTAMP}, #{issueDeleted,jdbcType=BIT})"
    })
    int insert(HaogoumallIssue record);

    @InsertProvider(type=HaogoumallIssueSqlProvider.class, method="insertSelective")
    int insertSelective(HaogoumallIssue record);

    @Select({
        "select",
        "issue_id, issue_question, issue_answer, issue_add_time, issue_update_time, issue_deleted",
        "from haogoumall_issue",
        "where issue_id = #{issueId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="issue_id", property="issueId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="issue_question", property="issueQuestion", jdbcType=JdbcType.VARCHAR),
        @Result(column="issue_answer", property="issueAnswer", jdbcType=JdbcType.VARCHAR),
        @Result(column="issue_add_time", property="issueAddTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="issue_update_time", property="issueUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="issue_deleted", property="issueDeleted", jdbcType=JdbcType.BIT)
    })
    HaogoumallIssue selectByPrimaryKey(Integer issueId);

    @UpdateProvider(type=HaogoumallIssueSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(HaogoumallIssue record);

    @Update({
        "update haogoumall_issue",
        "set issue_question = #{issueQuestion,jdbcType=VARCHAR},",
          "issue_answer = #{issueAnswer,jdbcType=VARCHAR},",
          "issue_add_time = #{issueAddTime,jdbcType=TIMESTAMP},",
          "issue_update_time = #{issueUpdateTime,jdbcType=TIMESTAMP},",
          "issue_deleted = #{issueDeleted,jdbcType=BIT}",
        "where issue_id = #{issueId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(HaogoumallIssue record);
}